<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*" %>   
<% request.setCharacterEncoding("utf-8"); %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<% 


/////////////////////////

List<String> msgList=(List<String>) application.getAttribute("msg");
if (msgList==null){
		msgList=new ArrayList();
	    application.setAttribute("msg",msgList);
}

    String s= request.getParameter("msgstr");
    if (s!=null&&!s.isEmpty())
    	msgList.add(s);
    

    	StringBuffer msg=new StringBuffer();
    	for(String m:msgList){	
    		msg.append(m).append("<br>");
    	}
    
 

%>
<div  style="width:500px;height:400px">
  <%=msg%>
</div>
<form action="chat.jsp" method="post">
 <input type=text name="msgstr" value=""> 
 <input type="submit" value="提交" > 
</form>
</body>
</html>